<template>
	<view class="page">
		<view class="name2">
			<text class="name2_1">{{info.sname}} {{info.dir}}</text>
			<view class="btn">
				<button class="btn_i" type="default" @click="btn">维保上传</button>
			</view>
		</view>
<view class="table">
			<zb-table :show-header="true" :columns="column" :stripe="true" :fit="false" 
				:border="true" :data="data"></zb-table>
		</view>
			<u-loadmore :status="status" :loadmoreText="loadmoreText" @loadmore="loadmore" />
		<tabbar :current="0"></tabbar>
	</view>
</template>

<script>
	import {
		findAppMaintenanceDeatil
	} from '@/api/common.js';
	export default {

		data() {
			return {
				page:1,
				pageCount:10,
				current: 0,
				status: 'loadmore',
				loadmoreText: '点击加载更多',
				column: [{
						name: 'people',
						label: '维保人',
						fixed: false,
						width: 154,
						type: 'wrap',
						emptyString: '--'
					},			
					{
						name: 'createDate',
						label: '时间',
						width: 136,
						sorter: true
					},
				],
				id: '1',
				data: [],
				info:{},
				status: 'loadmore',
				loadmoreText: '点击加载更多',
				page: 0,
				pageCount: 10,
				show_btn: true, //显示处理按钮
			}
		},
		onLoad: function(option) {
				console.log("onLoad:" + JSON.parse(option.info) )
			this.info = JSON.parse(option.info)
			this.id = this.info.id
		},
		onShow() {
			this.data=  []
			this.toSearch()
		},
		onReachBottom() {
			this.status = 'loading';
			console.log('触发上拉加载：' + this.status)
			this.page++;
			this.toSearch()
		},
		methods: {
			loadmore() {
				console.log('触发加载：' + this.status)
				this.page++;
					this.toSearch()
			},
			btn(){
				uni.navigateTo({
					url: '/pages/maintenance_service/maintenance_add?info=' + JSON.stringify(this.info)
				})
			},
			// rowClick(row, index) {
			// 	console.log('選中：' + JSON.stringify(row) + "--" + index)
			// 	uni.navigateTo({
			// 		url: '/pages/maintenance_service/maintenance_add?id=' + row.id
			// 	})
			// },
			//查詢設備列表
			toSearch(e) {
				console.log('----');
				console.log(this.id);
				findAppMaintenanceDeatil({
					siteid: this.id,
					pageSize: this.pageCount,
					page: this.page
				}).then(res => {
						if (res.records.length > 0){
							res.records.forEach(item =>{
								 this.data.push(item)
							})
						}
						if (res.hasNext == false) {
							this.status = 'nomore';
						}
						
				}).catch(err => {
					console.log(err);
					uni.showToast({
						title: err,
						icon: 'none'
					});
				// })
			})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.page {}

	.name2 {
		height: 120rpx;
		width: 84vw;
		@include flex();
		margin-bottom: 4vh;

		.name2_1 {
			color: $font-color;
			font-size: 40rpx;
			width: 100vw;
			text-align: center;
		}
	}

	.content {
		margin-top: 32rpx;

		.items {}
	}

	.btn {
		width: 280rpx;

		.btn_i {
			height: 68rpx;
			background-color: $bg-color;
			border-color: $bg-color;
			border-radius: 8rpx;
			color: white;
			font-size: 24rpx;
			text-align: center;
		}
	}
</style>